#车辆价格

import pandas as pd

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker

df=pd.read_csv("二手车基本信息.csv")

def price(x):
    if x<=5.0:
        return '五万元以下'
    elif 5.0<x<=10.0:
        return '5-10万'
    elif 10.0<x<=15.0:
        return '10-15万'
    elif 15.0<x<=20.0:
        return '15-20万'
    elif 20.0<x<=30.0:
        return '20-30万'
    else:
        return '30万以上'
df['价格分级']=df['价格(万元)'].apply(lambda x:price(x))
price_num =df['价格分级'].value_counts().tolist()
price_list=df['价格分级'].value_counts().index.tolist()
# print(price_num)


c = (
    Line()
    .add_xaxis(price_list)
    .add_yaxis("价格", price_num)
    .set_global_opts(title_opts=opts.TitleOpts(title="车辆价格"))
    .render("bigdata/cardata/车辆价格.html")
)

